package cmcciot.onenet.nbapi.sdk.entity;

import cmcciot.onenet.nbapi.sdk.config.Config;
import org.apache.commons.lang.StringUtils;

public class GetDeviceData extends CommonEntity{
    private String start;
    private String cursor;
    private String device_id;

    public GetDeviceData(String start, String cursor, String device_id) {
        this.start = start;
        this.cursor = cursor;
        this.device_id = device_id;
    }

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getCursor() {
        return cursor;
    }

    public void setCursor(String cursor) {
        this.cursor = cursor;
    }

    public String getDevice_id() {
        return device_id;
    }

    public void setDevice_id(String device_id) {
        this.device_id = device_id;
    }

    @Override
    public String toUrl() {
        StringBuilder url = new StringBuilder(Config.getDomainName());
        url.append("/devices/"+device_id+"/datapoints?start="+start);
        url.append((StringUtils.isEmpty(cursor)?"":("&cursor="+cursor)));
        url.append("&limit=6000");
        return url.toString();
    }
}
